<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
    <title>每日一句励志英语</title>
    <meta name="keywords" content="输出每日一句励志英语" />
    <meta name="description" content="输出每日一句励志英语" />
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/css/main.min.css" />
    <link rel="stylesheet" type="text/css" href="/css/ashes.min.css" />
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: #f5f5f5;
            margin: 0;
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 400px;
            width: 100%;
        }
        .container img {
            max-width: 100%;
            border-radius: 10px;
            margin-top: 10px;
        }
        .quote {
            font-size: 18px;
            margin: 20px 0;
        }
        .quote span {
            display: block;
            margin-bottom: 10px;
        }
        .button-container {
            display: flex;
            justify-content: space-between;
        }
        button {
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            border: none;
            border-radius: 5px;
            background-color: #007bff;
            color: white;
        }
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>每日一句励志英语</h1>
    <div class="quote">
        <span id="zh-quote">点击下方按钮获取每日一句</span>
        <span id="en-quote"></span>
    </div>
    <img id="quote-img" src="" alt="每日一句图片" style="display: none;">
    <!--，alt 属性用于为图像定义替代文本。替代文本通常用于在图像无法显示时进行说明。alt 属性对于可访问性和搜索引擎优化很重要。

alt 属性: 用于指定图像的替代文本，以便在图像无法显示时提供信息。 -->
    <div class="button-container">
        <button onclick="fetchDailyQuote()">获取当天句子</button>
        <button onclick="fetchRandomQuote()">获取随机句子</button>
    </div>
</div>
<script>
    function fetchQuote(url) {
        fetch(url)
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    document.getElementById('zh-quote').innerText = data.data.zh;
                    document.getElementById('en-quote').innerText = data.data.en;
                    const img = document.getElementById('quote-img');
                    img.src = data.data.pic;
                    img.style.display = 'block';
                }
            })
            .catch(error => {
                console.error('Error fetching quote:', error);
            });
    }

    function fetchDailyQuote() {
        fetchQuote('https://api.vvhan.com/api/dailyEnglish');
    }

    function fetchRandomQuote() {
        fetchQuote('https://api.vvhan.com/api/dailyEnglish?type=sj');
    }
</script>
</body>
</html>
